﻿using System;
using System.Threading.Tasks;
using SocketIOClient.WinRT.Helpers;

namespace SocketIOClient.WinRT
{
	/// <summary>
	/// C# Socket.IO client interface
	/// </summary>
	interface IClient
	{
		event EventHandler Opened;
		event EventHandler<MessageEventArgs> Message;
		event EventHandler SocketConnectionClosed;
		event EventHandler<ErrorEventArgs> Error;

		SocketIOHandshake HandShake { get; }
		bool IsConnected { get; }
		WebSocketState ReadyState { get; }

        Task ConnectAsync(string userId = null, string password = null);
        Task<IEndPointClient> ConnectEndpointAsync(string endPoint, string userId = null, string password = null);

		void Close();
		void Dispose();

		void On(string eventName, Action<Messages.IMessage> action);
		void On(string eventName, string endPoint, Action<Messages.IMessage> action);

		//void Emit(string eventName, dynamic payload);
		void Emit(string eventName, dynamic payload, string endPoint = "", Action<dynamic> callBack = null);
		
		void Send(Messages.IMessage msg);
		//void Send(string rawEncodedMessageText);
	}
}
